package com.gitee.cashzhang27.test.boot.crypt.mapper.entity;

import java.util.List;

/**
 * @author cash Zhang
 * @since : 2018/12/09 11:04
 */
public class TableResultResponse<T> {

  private int status = 200;
  private String message;
  private TableData<T> data;

  public TableResultResponse(long total, List<T> rows) {
    this.data = new TableData<T>(total, rows);
  }

  public TableResultResponse() {
    this.data = new TableData<T>();
  }

  TableResultResponse<T> total(int total) {
    this.data.setTotal(total);
    return this;
  }

  TableResultResponse<T> total(List<T> rows) {
    this.data.setRows(rows);
    return this;
  }

  public TableData<T> getData() {
    return data;
  }

  public void setData(TableData<T> data) {
    this.data = data;
  }

  public class TableData<T> {

    long total;
    List<T> rows;

    public TableData(long total, List<T> rows) {
      this.total = total;
      this.rows = rows;
    }

    public TableData() {
    }

    public long getTotal() {
      return total;
    }

    public void setTotal(long total) {
      this.total = total;
    }

    public List<T> getRows() {
      return rows;
    }

    public void setRows(List<T> rows) {
      this.rows = rows;
    }
  }
}
